import React, {useState} from 'react';
import ReactDOM from 'react-dom';


// Function that returns a function
const App = (props) => {
  const [value, setValue] = useState(10)

  /* const hello = (who) => {
    const handler = () => {
      console.log('hello ', who)
    }
    return handler
  }

  return (
    <div>
      {value}
      <button onClick={hello('world')}>button</button>
      <button onClick={hello('react')}>button</button>
      <button onClick={hello('function')}>button</button>
    </div>
  ) 
*/
  const setToValue = (newValue) => () => {
    setValue(newValue)
  }

  return (
    <div>
      {value}
      <button onClick={setToValue(1000)}>thousand</button>
      <button onClick={setToValue(0)}>reset</button>
      <button onClick={setToValue(value + 1)}>increment</button>
    </div>
  )
}

ReactDOM.render(<App />, document.getElementById('root'))
